<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<title>SlickGrid example 2: Formatters</title>
		<link rel="stylesheet" href="../slick.grid.css" type="text/css" media="screen" charset="utf-8" />
        <link rel="stylesheet" href="../css/smoothness/jquery-ui-1.8.5.custom.css" type="text/css" media="screen" charset="utf-8" />
		<link rel="stylesheet" href="examples.css" type="text/css" media="screen" charset="utf-8" />
		<style>
		.cell-title {
			font-weight: bold;
		}

		.cell-effort-driven {
			text-align: center;
		}
	</style>
	</head>
	<body>
		<table width="100%">
		<tr>
			<td valign="top" width="50%">
				<div id="myGrid" style="width:600px;height:500px;"></div>
			</td>
			<td valign="top">
				<h2>Demonstrates:</h2>
				<ul>
					<li>width, minWidth, maxWidth, resizable, cssClass column attributes</li>
					<li>custom column formatters</li>
					<li>rowCssClasses option</li>
				</ul>
			</td>
		</tr>
		</table>

		<script language="JavaScript" src="../lib/firebugx.js"></script>

		<script language="JavaScript" src="../lib/jquery-1.4.3.min.js"></script>
		<script language="JavaScript" src="../lib/jquery-ui-1.8.5.custom.min.js"></script>
		<script language="JavaScript" src="../lib/jquery.event.drag-2.0.min.js"></script>

		<script language="JavaScript" src="../slick.editors.js"></script>
		<script language="JavaScript" src="../slick.grid.js"></script>

        <script>
		var grid;

		var data = [];

		var columns = [
			{id:"title", name:"Title", field:"title", width:120, cssClass:"cell-title"},
			{id:"duration", name:"Duration", field:"duration"},
			{id:"%", name:"% Complete", field:"percentComplete", width:80, resizable:false, formatter:GraphicalPercentCompleteCellFormatter},
			{id:"start", name:"Start", field:"start", minWidth:60},
			{id:"finish", name:"Finish", field:"finish", minWidth:60},
			{id:"effort-driven", name:"Effort Driven", sortable:false, width:80, minWidth:20, maxWidth:80, cssClass:"cell-effort-driven", field:"effortDriven", formatter:BoolCellFormatter}
		];

		var options = {
			editable: false,
			enableAddRow: false,
			enableCellNavigation: true,
			rowCssClasses: function(item) {
				// if a task is 100% done then its row gets an additional CSS class
				return (item.percentComplete == 100) ? 'complete' : '';
			}
		};


		$(function()
		{
			for (var i=0; i<500; i++) {
				var d = (data[i] = {});

				d["title"] = "Task " + i;
				d["duration"] = "5 days";
				d["percentComplete"] = Math.min(100, Math.round(Math.random() * 110));
				d["start"] = "01/01/2009";
				d["finish"] = "01/05/2009";
				d["effortDriven"] = (i % 5 == 0);
			}

			grid = new Slick.Grid($("#myGrid"), data, columns, options);
		})

		</script>

	</body>
</html>
